<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <button onclick="hello()">hello</button>
    <button onclick="guess()">让我猜猜</button>
    <button onclick="guess1(56,100)">新猜猜</button>
    <button onclick="test(100)">test</button>



    <script>
        
        let value = 100;

        //实参
        grade(value);

        
        //函数的升格
        function grade(aaa){
            //形参
                    alert(aaa)
                }
       
        
        

       
        


        function hello(){
            alert("hello world")
        }

        function guess(){
            let right = 17;
            let num = +prompt("请猜数字")

            if(num==right){
                alert('you win');

                //结束当前循环体
                
            }else if(num>right){
                alert("bigger")
            }else{
                alert('less')
            }
        }

        //函数语法

        // function 函数名([参数值]){

        //     逻辑

        // }

        //匿名函数
        // function(){

        // }

        //箭头函数

        let test = () => alert("箭头函数")

        //等同于

        /* 
        let test =function(){
            alert("箭头函数")
        }
        */

        //传递参数的函数
        let guess1  = function(right,max){
            let num = +prompt("请猜数字")

            if(num>max){
                alert("超过范围了,请重新尝试")
            }

            if(num==right){
                alert('you win');

                //结束当前循环体
                
            }else if(num>right){
                alert("bigger")
            }else{
                alert('less')
            }
        }
        let num = 100;
        let num1 = 10;

        function add(addNum){
            return num1+addNum
        }

        let num2 = add(1000);

        console.log(num2)

    </script>
</body>
</html>